package lpg;

class Symbol implements Comparable<Symbol>
{
    Symbol(String name, int poolIndex)
    {
        this.name = name;
        this.poolIndex = poolIndex;
    }

    String name()
    {
        return name;
    }

    int index()
    {
        return poolIndex;
    }

    Token location()
    {
        return location;
    }

    void setLocation(Token location)
    {
        this.location = location;
    }

    public boolean equals(Object obj)
    {
        if (obj == this)
            return true;
        if (!(obj instanceof Symbol))
            return false;
        return name.equals(((Symbol)obj).name);
    }

    public int hashCode()
    {
        return name.hashCode();
    }

    public int compareTo(Symbol o)
    {
        return name.compareTo(o.name);
    }

    protected final String name;
    protected final int poolIndex;
    protected Token location = null;

}
